<?php if(!defined("HDPHP_PATH"))exit;C("SHOW_NOTICE",FALSE);?><!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title>添加商品类型</title>
	<script type='text/javascript' src='http://127.0.0.1/teacherShop/hdphp/hdphp/Extend/Org/Jquery/jquery-1.8.2.min.js'></script>
<link href='http://127.0.0.1/teacherShop/hdphp/hdphp/../hdjs/css/hdjs.css' rel='stylesheet' media='screen'>
<script src='http://127.0.0.1/teacherShop/hdphp/hdphp/../hdjs/js/hdjs.js'></script>
<script src='http://127.0.0.1/teacherShop/hdphp/hdphp/../hdjs/js/slide.js'></script>
<script src='http://127.0.0.1/teacherShop/hdphp/hdphp/../hdjs/org/cal/lhgcalendar.min.js'></script>
<script type='text/javascript'>
		HOST = 'http://127.0.0.1';
		ROOT = 'http://127.0.0.1/teacherShop';
		WEB = 'http://127.0.0.1/teacherShop/index.php';
		URL = 'http://127.0.0.1/teacherShop/index.php/Admin/Goods/save/gid/5';
		HDPHP = 'http://127.0.0.1/teacherShop/hdphp/hdphp';
		HDPHPDATA = 'http://127.0.0.1/teacherShop/hdphp/hdphp/Data';
		HDPHPTPL = 'http://127.0.0.1/teacherShop/hdphp/hdphp/Lib/Tpl';
		HDPHPEXTEND = 'http://127.0.0.1/teacherShop/hdphp/hdphp/Extend';
		APP = 'http://127.0.0.1/teacherShop/index.php/Admin';
		CONTROL = 'http://127.0.0.1/teacherShop/index.php/Admin/Goods';
		METH = 'http://127.0.0.1/teacherShop/index.php/Admin/Goods/save';
		GROUP = 'http://127.0.0.1/teacherShop/my';
		TPL = 'http://127.0.0.1/teacherShop/my/myshop/Admin/Tpl';
		CONTROLTPL = 'http://127.0.0.1/teacherShop/my/myshop/Admin/Tpl/Goods';
		STATIC = 'http://127.0.0.1/teacherShop/Static';
		PUBLIC = 'http://127.0.0.1/teacherShop/my/myshop/Admin/Tpl/Public';
		HISTORY = 'http://127.0.0.1/teacherShop/index.php/Admin/Goods/index';
		HTTPREFERER = 'http://127.0.0.1/teacherShop/index.php/Admin/Goods/index';
</script>
	<script type="text/javascript" src="http://127.0.0.1/teacherShop/my/myshop/Admin/Tpl/Goods/js/js.js"></script>
	<script type="text/javascript" src="http://127.0.0.1/teacherShop/my/myshop/Admin/Tpl/Goods/js/addSpec.js"></script>
</head>
<body>
	<div class="menu_list">
		<ul>
			<li><a href="<?php echo U('index');?>">商品列表</a></li>
			<li><a href="<?php echo U('add');?>"  class="action">添加商品</a></li>
		</ul>
	</div>
	<div class="title-header">添加商品</div>
	<div class="tab">
		<ul class="tab_menu">
			<li lab="base">
				<a> 基本参数</a>
			</li>
			<li lab="content" class="action">
				<a>内容</a>
			</li>
			<li lab='pic'>
				<a>图片</a>
			</li>
		</ul>
		<form action="" class="hd-form" method="post" enctype="multipart/form-data">
			<input type="hidden" name="cname" value="<?php echo $data['cname'];?>">
			<input type="hidden" name="gtname" value="<?php echo $goodsType[$data['gtid']]['gtname'];?>">
			<input type="hidden" name="gtid" value="<?php echo $data['gtid'];?>">
			<input type="hidden" name="cid" value="<?php echo $data['cid'];?>">

			<!-- <?php $hd["list"]["stid"]["total"]=0;if(isset($attrSpecForm) && !empty($attrSpecForm)):$_id_stid=0;$_index_stid=0;$laststid=min(1000,count($attrSpecForm));
$hd["list"]["stid"]["first"]=true;
$hd["list"]["stid"]["last"]=false;
$_total_stid=ceil($laststid/1);$hd["list"]["stid"]["total"]=$_total_stid;
$_data_stid = array_slice($attrSpecForm,0,$laststid);
if(count($_data_stid)==0):echo "";
else:
foreach($_data_stid as $key=>$stid):
if(($_id_stid)%1==0):$_id_stid++;else:$_id_stid++;continue;endif;
$hd["list"]["stid"]["index"]=++$_index_stid;
if($_index_stid>=$_total_stid):$hd["list"]["stid"]["last"]=true;endif;?>

				<input type="hidden" name="stid[]" value="<?php echo $stid['stid'];?>">
			<?php $hd["list"]["stid"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?> -->
			<div class="tab_content">
				<div id="base">
					<table class="table1">
						<tr>
							<th class="w100"> 商品名称 </th>
							<td >
								<input type="text" name="gname" class="w500" value="<?php echo $data['gname'];?>"/>
							</td>
						</tr>
						<tr>
							<th>栏目</th>
							<td><?php echo $data['cname'];?></td>
						</tr>
						<tr>
							<th>商品类型</th>
							<td><?php echo $goodsType[$data['gtid']]['gtname'];?></td>
						</tr>
						<tr>
							<th>属性</th>
							<td>
								<table>
									<?php $hd["list"]["n"]["total"]=0;if(isset($attrForm) && !empty($attrForm)):$_id_n=0;$_index_n=0;$lastn=min(1000,count($attrForm));
$hd["list"]["n"]["first"]=true;
$hd["list"]["n"]["last"]=false;
$_total_n=ceil($lastn/1);$hd["list"]["n"]["total"]=$_total_n;
$_data_n = array_slice($attrForm,0,$lastn);
if(count($_data_n)==0):echo "";
else:
foreach($_data_n as $key=>$n):
if(($_id_n)%1==0):$_id_n++;else:$_id_n++;continue;endif;
$hd["list"]["n"]["index"]=++$_index_n;
if($_index_n>=$_total_n):$hd["list"]["n"]["last"]=true;endif;?>

										<tr>
											<th><?php echo $n['attr_name'];?></th>
											<td><?php echo $n['html'];?></td>
										</tr>
									<?php $hd["list"]["n"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
								</table>
							</td>
						</tr>
						<?php if(!empty($attrSpecForm)){?>
						<tr>
							<th>规格</th>
							<td>
								<table id="GuiGe">
										
											<?php $hd["list"]["spec"]["total"]=0;if(isset($attrSpecForm) && !empty($attrSpecForm)):$_id_spec=0;$_index_spec=0;$lastspec=min(1,count($attrSpecForm));
$hd["list"]["spec"]["first"]=true;
$hd["list"]["spec"]["last"]=false;
$_total_spec=ceil($lastspec/1);$hd["list"]["spec"]["total"]=$_total_spec;
$_data_spec = array_slice($attrSpecForm,0,$lastspec);
if(count($_data_spec)==0):echo "";
else:
foreach($_data_spec as $key=>$spec):
if(($_id_spec)%1==0):$_id_spec++;else:$_id_spec++;continue;endif;
$hd["list"]["spec"]["index"]=++$_index_spec;
if($_index_spec>=$_total_spec):$hd["list"]["spec"]["last"]=true;endif;?>

											<tr class="title-header">
												<?php $hd["list"]["web"]["total"]=0;if(isset($spec['html']) && !empty($spec['html'])):$_id_web=0;$_index_web=0;$lastweb=min(1000,count($spec['html']));
$hd["list"]["web"]["first"]=true;
$hd["list"]["web"]["last"]=false;
$_total_web=ceil($lastweb/1);$hd["list"]["web"]["total"]=$_total_web;
$_data_web = array_slice($spec['html'],0,$lastweb);
if(count($_data_web)==0):echo "";
else:
foreach($_data_web as $key=>$web):
if(($_id_web)%1==0):$_id_web++;else:$_id_web++;continue;endif;
$hd["list"]["web"]["index"]=++$_index_web;
if($_index_web>=$_total_web):$hd["list"]["web"]["last"]=true;endif;?>

													<td><?php echo $web['attr_name'];?></td>
												<?php $hd["list"]["spec"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
												<td class="w50">价格</td>
												<td class="w50">库存</td>
												<td class="w50">货号</td>
												<td class="w150">样图</td>
												<td class="w150"><a onclick="addSpec(this)" cursor="pointer" href="javascript:">添加规格</a></td>
												<td class="w100">替换样图</td>
											</tr>
											<?php $hd["list"]["web"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
											
										
										
											<?php $hd["list"]["spec"]["total"]=0;if(isset($attrSpecForm) && !empty($attrSpecForm)):$_id_spec=0;$_index_spec=0;$lastspec=min(1000,count($attrSpecForm));
$hd["list"]["spec"]["first"]=true;
$hd["list"]["spec"]["last"]=false;
$_total_spec=ceil($lastspec/1);$hd["list"]["spec"]["total"]=$_total_spec;
$_data_spec = array_slice($attrSpecForm,0,$lastspec);
if(count($_data_spec)==0):echo "";
else:
foreach($_data_spec as $key=>$spec):
if(($_id_spec)%1==0):$_id_spec++;else:$_id_spec++;continue;endif;
$hd["list"]["spec"]["index"]=++$_index_spec;
if($_index_spec>=$_total_spec):$hd["list"]["spec"]["last"]=true;endif;?>

												<tr class="gg">
												<?php $hd["list"]["web"]["total"]=0;if(isset($spec['html']) && !empty($spec['html'])):$_id_web=0;$_index_web=0;$lastweb=min(1000,count($spec['html']));
$hd["list"]["web"]["first"]=true;
$hd["list"]["web"]["last"]=false;
$_total_web=ceil($lastweb/1);$hd["list"]["web"]["total"]=$_total_web;
$_data_web = array_slice($spec['html'],0,$lastweb);
if(count($_data_web)==0):echo "";
else:
foreach($_data_web as $key=>$web):
if(($_id_web)%1==0):$_id_web++;else:$_id_web++;continue;endif;
$hd["list"]["web"]["index"]=++$_index_web;
if($_index_web>=$_total_web):$hd["list"]["web"]["last"]=true;endif;?>

													<td><?php echo $web['web'];?></td>
												<?php $hd["list"]["spec"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
												<td><input type="text" class='ggPrice' name="spec[price][]" id="" value="<?php echo $spec['price'];?>"></td>
												<td><input type="text" class='ggStock' name="spec[stock][]" id="" value="<?php echo $spec['stock'];?>"></td>
												<td><input type="text" name="spec[goods_sn][]" id="" value="<?php echo $spec['goods_sn'];?>"></td>
												
												<td><img src="http://127.0.0.1/teacherShop/<?php echo $spec['small'];?>" alt="" style="width:50px;height:50px;"></td>
												<td ><a onclick="delStockData(this)" stid="<?php echo $spec['stid'];?>" cursor="pointer" href="javascript:">删除规格</a></td>
												<td ><input type="file" name="pics[]"/></td>
												<td><input type="hidden" name="spec[stid][]" value="<?php echo $spec['stid'];?>"></td>
												<td id="spec_pic"><input type="hidden" name="spec[stock_pic][]" value="<?php echo $spec['stock_pic'];?>"></td>
												<td id="spec_picid"><input type="hidden" name="spec[pic_id][]" value="<?php echo $spec['pic_id'];?>"></td>
												</tr>
											<?php $hd["list"]["web"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
											<!-- <td><input type="text" name="spec[price][]" id=""></td>
											<td><input type="text" name="spec[stock][]" id=""></td>
											<td><input type="text" name="spec[goods_sn][]" id=""></td> -->
								</table>
							</td>
							
						</tr>		
						<?php }?>
						<tr>
							<th> 最低价 </th>
							<td>
								<input type="text" name="price" class="w400" value="<?php echo $data['price'];?>"/>
							</td>
						</tr>
						<tr>
							<th> 总库存 </th>
							<td>
								<input type="text" name="stock" class="w400" value="<?php echo $data['stock'];?>"/>
							</td>
						</tr>
						<tr>
							<th> 关键字 </th>
							<td>
								<input type="text" name="keywords" class="w400" value="<?php echo $data['k'];?>"/>
							</td>
						</tr>
						<tr>
							<th> 描述 </th>
							<td>
								<textarea name="description" id="" cols="30" rows="10" class="w400 h100"><?php echo $data['dsc'];?></textarea>
							</td>
						</tr>
						
						<tr>
							<th> 录入时间 </th>
							<td>
								<input type="text" name="addtime" id="addtime" readonly="readonly" value="<?php echo date('Y/m/d h:i:s');?>"/>
							</td>
							<script>
								
									$('#addtime').calendar({format:'yyyy/MM/dd HH:mm:ss'});
								
							</script>
							
						</tr>
						
						<tr>
							<th> 服务 </th>
							<td>
								<input type="text" name="service" value="<?php echo $data['service'];?>"/>
							</td>
						</tr>
						<tr>
							<th> 点击量 </th>
							<td>
								<input type="text" name="click" value="<?php echo $data['click'];?>"/>
							</td>
						</tr>
					</table>
				</div>
				<div id="content">
					<table class="table1">
						<tr>
							<th class="w100">内容</th>
							<td>
								<script type="text/javascript" charset="utf-8" src="http://127.0.0.1/teacherShop/hdphp/hdphp/Extend/Org/Ueditor/ueditor.config.js"></script><script type="text/javascript" charset="utf-8" src="http://127.0.0.1/teacherShop/hdphp/hdphp/Extend/Org/Ueditor/ueditor.all.min.js"></script><script type="text/javascript">UEDITOR_HOME_URL="http://127.0.0.1/teacherShop/hdphp/hdphp/Extend/Org/Ueditor/"</script><script id="hd_body" name="body" type="text/plain"><?php echo $data['body'];?></script>
        <script type='text/javascript'>
        $(function(){
                var ue = UE.getEditor('hd_body',{
                imageUrl:'http://127.0.0.1/teacherShop/index.php?a=Admin&c=Goods&gid=5&m=ueditor_upload&g=myshop&water=0&uploadsize=2000000&maximagewidth=false&maximageheight=false'//处理上传脚本
                ,zIndex : 0
                ,autoClearinitialContent:false
                ,initialFrameWidth:"100%" //宽度1000
                ,initialFrameHeight:"300" //宽度1000
                ,autoHeightEnabled:false //是否自动长高,默认true
                ,autoFloatEnabled:false //是否保持toolbar的位置不动,默认true
                ,maximumWords:2000 //允许的最大字符数
                ,readonly : false //编辑器初始化结束后,编辑区域是否是只读的，默认是false
                ,wordCount:true //是否开启字数统计
                ,imagePath:''//图片修正地址
                , toolbars:[
            ['fullscreen', 'source', '|', 'undo', 'redo', '|',
                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                'directionalityltr', 'directionalityrtl', 'indent', '|',
                'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
                'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe','insertcode', 'pagebreak', 'template', 'background', '|',
                'horizontal', 'date', 'time', 'spechars',  'wordimage', '|',
                'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
                'print', 'preview', 'searchreplace']
            ]//工具按钮
                , initialStyle:'p{line-height:1em; font-size: 14px; }'
            });
        })
        </script>
							</td>
						</tr>
						
					</table>
				</div>

				<div id="pic">
					<table class="table1">
						<tr>
							<th class="w100">产品主图</th>
							<td>
								<input type="file" name="index_pic"/>
							</td>
							<td><img src="http://127.0.0.1/teacherShop/<?php echo $data['index_pic'];?>" alt="" class="w100"></td>
							<input type="hidden" name="in_pic" id="" value="<?php echo $data['index_pic'];?>">
						</tr>
						<tr>
							<th> 列表页图 </th>
							<td>
								<input type="file" name="list_pic"/>
							</td>
							<td><img src="http://127.0.0.1/teacherShop/<?php echo $data['list_pic'];?>" alt="" class="w100"></td>
							<input type="hidden" name="li_pic" id="" value="<?php echo $data['list_pic'];?>">
						</tr>

						<tr>
							<th> 内容页图 </th>

							<td>
								<ul id="old_cpics" style="width:700px;">
									<?php $hd["list"]["pic"]["total"]=0;if(isset($pics) && !empty($pics)):$_id_pic=0;$_index_pic=0;$lastpic=min(1000,count($pics));
$hd["list"]["pic"]["first"]=true;
$hd["list"]["pic"]["last"]=false;
$_total_pic=ceil($lastpic/1);$hd["list"]["pic"]["total"]=$_total_pic;
$_data_pic = array_slice($pics,0,$lastpic);
if(count($_data_pic)==0):echo "";
else:
foreach($_data_pic as $key=>$pic):
if(($_id_pic)%1==0):$_id_pic++;else:$_id_pic++;continue;endif;
$hd["list"]["pic"]["index"]=++$_index_pic;
if($_index_pic>=$_total_pic):$hd["list"]["pic"]["last"]=true;endif;?>

										<li style="float:left;margin-right:10px;position:relative;">
											<img src="http://127.0.0.1/teacherShop/<?php echo $pic['small'];?>" alt="" class="w150">
											<span id="spandelpic" onclick="delold(this)" picid="<?php echo $pic['pic_id'];?>" style="border:1px solid #333;text-align:center;font-wigth:700;cursor:pointer;display:block;width:15px;height:20px;line-height:20px;background:#fff;position:absolute;top:3px;right:5px;z-index:5px;">X</span>

										</li>
									<?php $hd["list"]["pic"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
								</ul>
								<div style="clear:both;">
								<input type="file" name="pics[]"/>
								<button class="hd-cancel" type="button" onclick="addPics();">添加</button></div>

								<ul id="content_pic" style="margin-top:5px;">

								</ul>
							</td>
							
						</tr>

						
					</table>
				</div>
			</div>
			<input type="submit" value="添加" name="submit" class="hd-success position-bottom" style="margin-left:30px;">

		</form>
	</div>
		
	<script>
		validate:{
			$(function(){
				$('form').validate({
					gname:{
						rule:{
							required:true
						},
						error:{
							required:'商品名不能为空'
						}
					}
					
				})
			})
		}
	</script>
</body>
</html>